#ifndef BLOCKRELAXATION_H
#define BLOCKRELAXATION_H

#include "Core/Tensor.h"
#include "Core/RowSparse.h"
#include "Embedded/EmbeddedGrid.h"

template <int Dim>
class BlockRelaxation
{
public:
  using iVec = Vec<int, Dim>;
  using EmGrid = EmbeddedGrid<Dim>;

  BlockRelaxation(const EmGrid &emGrid, const RowSparse<iVec> &aSparseOp, Real splitThr);

  void apply(Tensor<Real, Dim> &aPhi, const Tensor<Real, Dim> &rhs) const;

protected:
  const RowSparse<iVec> &originalOp;
  Tensor<Real, 2>       diagBlock;
  RowSparse<iVec>       offDiagBlock;
  int                   blockSize;
  Tensor<int, 1>        ipiv;
};

#endif //BLOCKRELAXATION_H
